home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Scripts / PixelPaintPro.vu < prev    next >
Encoding:
Text File  |  1993-12-17  |  15.9 KB  |  451 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        PixelPaintPro.vu
  5. #
  6. #    Contains:    Quick look test script for PixelPaint Pro version 2.0.1
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #     <1.0.8>    12/13/93    KTA        Added global gCustomRetrievedDoc := [window
  19. #                                    t:/@•@-{gBuildVers}≈/], so OpenFile TCS wouldn't fail.
  20. #     <1.0.7>     9/30/93    KTA        Initialize gFileName prior to gApptitle being updated by
  21. #                                    launchTwitch().
  22. #     <1.0.6>     9/28/93    KTA        Added returnVal for ModifyDocument hook.
  23. #     <1.0.3>     7/19/93    KTA        Updates for FindWindow() to handle descriptors.
  24. #     <1.0.2>     6/16/93    NAGA        Renaming InitGlobals(ScriptLevel)to InitGlobals(ScriptLevel)
  25. #        <1+>     5/25/93    NAGA        Adding header and porting old files to follow new standards
  26. #
  27. # ****************************************************************************
  28. #
  29.  
  30.  
  31.  
  32. ########################################################################
  33. #                            External libraries 
  34. #=======================================================================
  35. Libraries "Output.Lib", "DoTasks.Lib","Draw.Lib","UserInterface.Lib","DA.Lib", "Font.Lib", "Globals.Lib", "LaunchQuit.Lib", "TCS.Lib";
  36.  
  37.  
  38. #########################################################################
  39. ########               Application Specific Tasks
  40. #########################################################################
  41.  
  42. #########################################################################
  43. #                        InitAppGlobals()
  44. #========================================================================
  45. # Author:        GS
  46. # Description:    Sets up tools and fonts for PixelPaint Pro.  This task
  47. #                must be called first.
  48. # Parameters:    None
  49. # Returns:        Nothing
  50. # Examples:        InitAppGlobals()
  51. #========================================================================
  52. # History:
  53. #
  54. ########################################################################
  55. task InitAppGlobals()
  56. begin
  57.     
  58.     logstr("setting up {global gApptitle}'s globals");            
  59.     global kClick, kDrag, kDragClick, kMultiDrag, kMultiClickDrag, kMultiClick;
  60.     global kPalDocWind, kPalWind, kPullOffPal, kPopUpPal, kScrollPal, gTextStr;
  61.     
  62.     global gWindowInset            := {0,43,20,20};
  63.  
  64.     global kToolPaletteNum         := 1; 
  65.     global kColorPaletteNum     := 2;
  66.     global kPatternPaletteNum     := 3;
  67.     global kLinePaletteNum        := 4;
  68.  
  69.     global gPaletteList := {
  70.                             {     
  71.                             {'≠Full≠',11},                #Main Tool Matrix (Pallete #1)
  72.                             kPalWind,
  73.                             {3,8},                        #tool matrix
  74.                             {30,22}                        #tool offset
  75.                             },
  76.                             
  77.                             {
  78.                             {57,274, 86,260,'≠Full≠'},    #Color popup (Pallete #2)
  79.                             kPopUpPal,
  80.                             {16,16},
  81.                             { 9,9}
  82.                             },
  83.                             
  84.                             {
  85.                             {60,204, 85,192,'≠Full≠'},    #Pattern popup (Pallete #3)
  86.                             kPopUpPal,
  87.                             {5,5},
  88.                             {20,20}
  89.                             },
  90.                             
  91.                             {
  92.                             {61,227, 89,228, '≠Full≠'},    #Lines (Pallete #4)
  93.                             kPopUpPal,
  94.                             {8,8},
  95.                             {11,11}
  96.                             }
  97.                           };
  98.  
  99.     ### Palette Elements:=        Tool#, Pal#,     ToolName,         ToolType,    DblClktoEnd        SetAttributes
  100.     global FreeSelectTool     :=     { 1,  1,        "FreeSelect",    kMultiDrag, 0,                {0}                };
  101.     global RectSelectTool    :=    { 2,  1,        "RectSelect",     kDrag,        0,                {0}                };
  102.     global WandTool            :=  { 3,  1,        "HandTool",     kClick,     0,              {0}                };
  103.     #global croptool
  104.     global MagnifyTool        :=  { 5,  1,        "MagnifyTool",  kClick,     0,              {0}                };
  105.     global ColorPickup        :=  { 6,  1,        "ColorPickup",    kClick,        0,                {0}                };
  106.     global PaintBrush        :=    { 7,  1,         "PaintBrush",    kMultiDrag,    0,                {1,1,0,1}        };
  107.     global PencilTool        :=  { 8,  1,        "PencilTool",    kMultiDrag,    0,                {1,1,1,1}        };
  108.     global Eraser            :=  { 9,  1,        "Eraser",        kMultiDrag, 0,                {0}                };
  109.     global BlendTool        :=  {10,  1,        "BlendTool",    kMultiDrag, 0,                {0}                };
  110.     global AirBrush            :=  {11,  1,        "AirBrush",        kMultiDrag, 0,                {1,1,0,1}        };
  111.     global SmudgeTool        :=  {12,  1,        "Smudge",        kMultiDrag, 0,                {0}                };
  112.     global PastelTool        :=    {13,  1,         "PastelTool",    kMultiDrag,    0,                {1,1,0,1}        };
  113.     global CharcoalTool        :=    {14,  1,         "CharcoalTool",    kMultiDrag,    0,                {1,1,0,1}        };
  114.     #global rubberstamp
  115.     global LineTool         :=     {16,  1,         "Line",            kDrag,         1,                {1,0,1,0}        };
  116.     #global BezierTool
  117.     #note chartool is really a double click and needs to be implemented as such!!
  118.     global Chartool            :=  {18,  1,        "Chartool",     kClick,     0,              {1,0,0,1}        };
  119.     global RectTool         :=     {19,  1,        "Rectangle",    kDragClick,    1,                {1,0,0,1}        };
  120.     global OvalTool         :=     {20,  1,         "OvalTool",        kDragClick,    1,                {1,0,0,1}        };
  121.     global FillTool            :=  {21,  1,        "FillTool",        kClick,        0,                {1,0,0,1}        };
  122.     #global PolyTool
  123.     global FreeTool         :=     {23,  1,         "FreeTool",        kMultiDrag, 1,                {1,0,0,1}        };
  124.     global RegPolyTool         :=     {24,  1,         "RegPolyTool",    kDragClick,    0,                {1,0,0,1}        };
  125.  
  126.  
  127.     global gToolList:={    FreeSelectTool,
  128.                         RectSelectTool,
  129.                         WandTool,
  130.                         ColorPickup,
  131.                         PaintBrush,
  132.                         PencilTool,
  133.                         Eraser,
  134.                         BlendTool,
  135.                         AirBrush,
  136.                         SmudgeTool,
  137.                         PastelTool,
  138.                         CharcoalTool,
  139.                         LineTool,
  140.                         CharTool,
  141.                         RectTool,
  142.                         OvalTool,
  143.                         FillTool,
  144.                         FreeTool,
  145.                         RegPolyTool
  146.                       };
  147.                       
  148.     global gDocumentWindow := [window c:True g:True z:True]!;
  149.  
  150.     #gMagnifyTool is defined just not in the gToolList
  151.                       
  152.     #global gToolList:={FreeTool,RectTool,LineTool, RegPolyTool};                      
  153.  
  154.         ### font characteristic lists
  155.     # gFontList must be set up in same order as popup in app - don't use list defined in Globals.lib
  156.     global gFontList := {'Chicago','Courier','Geneva','Helvetica','Monaco', 'New York',
  157.     'Palatino','Symbol','Times'};
  158.     global gFontSizeList := {'9','10','12','14','18', '24','27','30','36','42','48'};
  159.     global gFontStyleList := {'Bold','Italic','Outline', 'Underline','Shadow'};
  160.  
  161.     
  162.         ### Name of the Plain (style) menu item  ####
  163.     global gPlainStyle := "Plain";            # Plain-Style menu item
  164.  
  165.         ### How to get to the next line
  166.     global gNextlineMethod := 1;            
  167.         ### 1 - ReturnKey,  2 - EnterKey, 3 - DownArrow Key, 4 - TabKey, {} - Move/Click, {'Untitled'} - Move relative to the window titled 'Untitled' /Click
  168.     
  169.         ### Does moving to the next line clear all font info
  170.     global gNextlineClearsFontSettings := 0;
  171.     
  172.     global gCurFontNo   := 1;                        #Initializes starting font for SetPPPFonts
  173.     global gSetFont        := Task SetPPPFonts;        #overrides SetFont Task Requires VU 2.0
  174.     global gSetSize        := Task SetPPPSize;            #overrides SetSize Task Requires VU 2.0
  175.     global gSetStyle    := Task SetPPPStyle;        #overrides SetStyle Task Requires VU 2.0
  176.     global gNextline    := Task PPPNextline;        # overrides Nextline Requires VU 2.0
  177.     global gReportSelectedMenuItems := Task PPPReportSelected; # overrides ReportSelectedMenuItems Task    
  178.  
  179. end;  # InitAppGlobals
  180.  
  181. #########################################################################
  182. #                        SetPPPFonts(pMyFont)
  183. #========================================================================
  184. # Author:        GS
  185. # Description:    Sets the currently selected font to <pMyFont> 
  186. # Parameters:    pMyFont - Name of the font.
  187. # Returns:        Nada
  188. # Examples:        SetPPPFonts('Geneva');
  189. # Assumptions:    That gFontList is correct and the fonts are in the list in 
  190. #                the order that they appear in the application 
  191. #                InitFonts was called before the 1st time SetPPPFont was called
  192. #========================================================================
  193. # History:
  194. #
  195. #########################################################################
  196. task SetPPPFonts(pMyFont, pMyObjectNum)
  197. begin                                                        #figure out how much to move 
  198.     global gCurFontNo;
  199.     toMov        := 0;
  200.     needToMov   := 0;
  201.     myFontNo    := 0;
  202.     
  203.     for i := 1 to card(global gFontList)
  204.         begin
  205.             if gFontList[i] = pMyFont                        #Which font number is it?
  206.                 begin
  207.                     myFontNo := i;
  208.                 end;
  209.                 
  210.         end;
  211.         toMov := myFontNo - gCurFontNo;
  212.         vMov         := 17;                                    #Each item in this list is {vMove} pixels apart
  213.         needToMov    := vMov * toMov;                        #How far to we need to move
  214.         moveRelativeToWindow(88,25,'TextDialog');            #Move to the popPoint
  215.         pressMouse;
  216.         move r:{0,needToMov};                               #Select the font
  217.         releaseMouse;
  218.         
  219.         gCurFontNo := myFontNo;
  220.  
  221. # println "this is the pMyFont - ", pMyFont;
  222. return(pMyFont);    
  223. end;    
  224.  
  225. #########################################################################
  226. #                        SetPPPStyle(pMyStyle)
  227. #========================================================================
  228. # Author:        GS
  229. # Description:    Sets the currently selected PPP font style to <pMyStyle> 
  230. # Parameters:    pMyStyle - Name of the Style.
  231. # Returns:        Nada
  232. # Examples:        SetStyle('Bold');
  233. # Assumptions:    None
  234. #========================================================================
  235. # History:
  236. #
  237. #########################################################################
  238. task SetPPPStyle(pMyStyle, pMyObjectNum) 
  239. begin
  240.     returnVal := 0;
  241.     if pMyStyle = global gPlainStyle
  242.     begin
  243.         y:= 0;
  244.         x := collect[checkbox s:{1,1}]!;
  245.         if(x)
  246.         begin
  247.             for each item in x 
  248.             begin
  249.                 y           := y +1;
  250.                 myCheckBox := x[y].t;
  251.                 SelectCheckBox(myCheckBox);
  252.             end;
  253.             returnVal := gPlainStyle;
  254.         end;
  255.     end;    
  256.     else
  257.         returnVal := SelectCheckBox(pMyStyle);
  258.     return(returnVal);
  259. end; # SetStyle()
  260.  
  261. #########################################################################
  262. #                        SetPPPSize(pMySize)
  263. #========================================================================
  264. # Author:        GS
  265. # Description:    Sets the currently selected font size to <pMySize> 
  266. # Parameters:    pMySize - Name of the size.
  267. # Returns:        Nada
  268. # Examples:        SetSize('10');
  269. # Assumptions:    None
  270. #========================================================================
  271. # History:
  272. #
  273. #########################################################################
  274. task SetPPPSize(pMySize, pMyObjectNum) 
  275. begin
  276.     MoveRelativeToWindow(58,49,'TextDialog',0);
  277.     doubleClick;            #select size text box
  278.     TypeStr(pMySize);
  279.     type k:{tabKey};        #Reselect main text box
  280.     type k:{tabKey};
  281.     return(pMySize);
  282. end; # SetSize()
  283.  
  284. #########################################################################
  285. #                        PPPNextline()
  286. #========================================================================
  287. # Author:        GS
  288. # Description:    Prepares application to accept the next line of text
  289. # Parameters:    None
  290. # Returns:        Nix
  291. # Examples:        PPPNextline();
  292. # Assumptions:    
  293. #========================================================================
  294. # History:
  295. #
  296. #########################################################################
  297. task PPPNextline() 
  298. begin
  299.     SpecialKey(EnterKey, "EnterKey");             # Clear the old dialog
  300.     click;
  301.     MoveRelativeToWindow(,,global gDocumentWindow);    # Move to a random point frontmost window
  302.     pressmouse;
  303.     wait(1);
  304.     releasemouse;
  305.     
  306. end; # PPPNextline()
  307.  
  308. #########################################################################
  309. #                        PPPReportSelected()
  310. #========================================================================
  311. # Author:        ML
  312. # Description:    Custom task to report font size and styles choosen
  313. # Parameters:    None
  314. # Returns:        Nix
  315. # Examples:        PPPReportSelected();
  316. # Assumptions:    
  317. #========================================================================
  318. # History:
  319. #
  320. #########################################################################
  321. task PPPReportSelected() 
  322. begin
  323.     # Need to add task to built list here!
  324. end; # PPPReportSelected()
  325.  
  326. #########################################################################
  327. #                            PPProModifyDocument()
  328. #========================================================================
  329. # Author:        ML
  330. # Description:    Modify PPPro Document
  331. # Parameters:    None
  332. # Returns:        Nothing
  333. # Examples:        PPProModifyDocument();
  334. # Assumptions:    None 
  335. # Applications:    PPPro
  336. #========================================================================
  337. # History:
  338. #
  339. #########################################################################
  340. task PPProModifyDocument()
  341. begin
  342.     logstr("Modifying the '{global gapptitle}' document...");
  343.     return(Scrapbook(global kScrapPict));
  344. end;
  345.  
  346. #########################################################################
  347. #                            PPProScrapText()
  348. #========================================================================
  349. # Author:        ML
  350. # Description:    Test PPPro scraptext
  351. # Parameters:    None
  352. # Returns:        Nothing
  353. # Examples:        PPProScrapText();
  354. # Assumptions:    None 
  355. # Applications:    PPPro
  356. #========================================================================
  357. # History:
  358. #
  359. #########################################################################
  360. task PPProScrapText()
  361. begin
  362.     MoveRelativeToWindow(71,5,1,2);    # show all tools in the tool pallete
  363.     Scrapbook(global kScraptext,,0);
  364.     PPProSetupDoText();                # set up to handle text
  365.     KeyEq('v');                        # VU thinks 'Paste' menuitem is disabled
  366.     SpecialKey(EnterKey, "EnterKey");             # Clear text dialog
  367. end;
  368.  
  369. #########################################################################
  370. #                            PPProSetupDoText()
  371. #========================================================================
  372. # Author:        ML
  373. # Description:    Set up for DoText()
  374. # Parameters:    None
  375. # Returns:        Nothing
  376. # Examples:        PPProSetupDoText();
  377. # Assumptions:    None 
  378. # Applications:    PPPro
  379. #========================================================================
  380. # History:
  381. #
  382. #########################################################################
  383. task PPProSetupDoText()
  384. begin
  385.     logstr("setting up for text...");
  386.     SetTool(global CharTool);                     # Select the tool
  387.     MoveRelativeToWindow(,,global gDocumentWindow,2);# Move to a random point frontmost window
  388.     pressmouse;                                    
  389.     wait(1);
  390.     releasemouse;
  391. end;
  392. #########################################################################
  393. #                            PPProClearDoText()
  394. #========================================================================
  395. # Author:        ML
  396. # Description:    clears DoText()
  397. # Parameters:    None
  398. # Returns:        Nothing
  399. # Examples:        PPProClearDoText();
  400. # Assumptions:    None 
  401. # Applications:    PPPro
  402. #========================================================================
  403. # History:
  404. #
  405. #########################################################################
  406. task PPProClearDoText()
  407. begin
  408.     logstr("clearing text entry...");
  409.     SpecialKey(DeleteKey, "Delete Key");         # Delete leftover text in dialog
  410.     SpecialKey(EnterKey, "EnterKey");             # Close text dialog
  411. end;
  412.  
  413. ################################################################################
  414. ####################             Main script                    ####################
  415. ################################################################################
  416. script PPPro (ScriptLevel:= -1)
  417. begin
  418.     InitGlobals(ScriptLevel);            # initialize your general globals
  419.     InitDraw();
  420.     InitFonts();
  421.     Global gApptitle := "PixelPaint Pro";
  422.     global gAppVersion := '2';        # version of app you will be running
  423.     global gFileName := "@!@-{gBuildVers}-{gAppTitle}";    # This is used in SaveAs when saving files
  424.     Global gLaunchReqs := {'fpu'};    # required to run app
  425.     SuiteStart('PixelPaintPro.vu');                    # begin a new test suite
  426.     if LaunchTwitch("{gAppTitle}",gAliasDirectory) # launch or twitch to your app
  427.     begin
  428.         global gModifyDocument := task PPProModifyDocument;    # define app specific task
  429.         global gCustomScrapText := task PPProScrapText;     # define app specific task    
  430.         global gSetupDoText := task PPProSetupDoText;        # define app specific task
  431.         global gReportSelectedMenuItems := task PPPReportSelected; 
  432.         global gCustomRetrievedDoc := [window t:/@•@-{gBuildVers}≈/]; # Note:'PPPro substitutes '•' for '!' in window title"
  433.         global gClearDoText := task PPProClearDoText;
  434.         InitAppGlobals();                                    # init app specific globals
  435.         (*
  436.         *)
  437.         DoSetUpApp(0,-1,,1,1,1,1);
  438.         DoDraw();
  439.         DoText();
  440.         DoWindow();                                        
  441.         DoCloseApp(1,4);
  442.         LogStr("############################# LIMITATIONS: ############################");
  443.         LogStr("NOTE: No TCS's for DoText are generated because PPPro used custom font
  444.         tasks to handle it's font dialog.");
  445.     end; # if LaunchTwitch("{gAppTitle}",gAliasDirectory)
  446.     SuiteEnd();
  447. end; # script PPPro
  448.  
  449. ### What's Needed
  450. # 1) Set up TCS's for custom tasks used in Dotext - SetPPPFonts, SetPPPSize, SetPPPStyle,
  451. #    PPPNextline, PPPReportSelected